package com.heer.gymnasium.activity;

import android.content.Intent;

import com.heer.gymnasium.R;
import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout;
import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection;

/**
 * Created by rzw2 on 2017/4/5.
 */

public class BaseRefreshActivity extends BaseActivity implements SwipyRefreshLayout.OnRefreshListener {
    protected SwipyRefreshLayout layoutRefresh;
    protected int pageNo = 1;

    @Override
    protected void initView() {
        super.initView();
        layoutRefresh = (SwipyRefreshLayout) findViewById(R.id.layout_refresh);
        layoutRefresh.setOnRefreshListener(this);
    }

    @Override
    public void onRefresh(SwipyRefreshLayoutDirection direction) {
        if (direction == SwipyRefreshLayoutDirection.TOP) {
            pageNo = 1;
            loadData(false);
        } else if (direction == SwipyRefreshLayoutDirection.BOTTOM) {

            pageNo++;
            loadData(true);
        }
    }

    protected void toLogin(){
        Intent intent = new Intent(mContext, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

}
